package sample.stream.service.listener;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Service;

@Service("receiveMessageListener")
@EnableBinding(Sink.class) //表明这是一个消息消费者
public class ReceiveMessageListener {

    @StreamListener(Sink.INPUT) //监听默认的“input”Channel（见配置文件resources/application-consumer-kafka-10034.yml）
    public void receive(Message<String> message){
        System.out.println("ReceiveMessageListener接收了以下消息："+message.getPayload().toString());
    }
}
